<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.9.2" />
<title>ascend.common.const API documentation</title>
<meta name="description" content="Copyright 2020 Huawei Technologies Co., Ltd
Licensed under the Apache License, Version 2.0 (the &#34;License&#34;);
you may not use this file except in …" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<link rel="preconnect" href="https://www.google.com">
<script async src="https://cse.google.com/cse.js?cx=017837193012385208679:pey8ky8gdqw"></script>
<style>
.gsc-control-cse {padding:0 !important;margin-top:1em}
body.gsc-overflow-hidden #sidebar {overflow: visible;}
</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
<style>.homelink{display:block;font-size:2em;font-weight:bold;color:#555;padding-bottom:.5em;border-bottom:1px solid silver}.homelink:hover{color:inherit}.homelink img{max-width:20%;max-height:5em;margin:auto;margin-bottom:.3em}</style>
<link rel="canonical" href="https://bazige.github.io/ascend/common/const.html">
<link rel="icon" href="https://bazige.github.io/ascend/logo/logo.png"">
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>ascend.common.const</code></h1>
</header>
<section id="section-intro">
<p>Copyright 2020 Huawei Technologies Co., Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/pdoc3/pdoc/blob/37c907488ff52b174ab602690d1166f28bded9a2/ascend/common/const.py#L0-L268" class="git-link">Browse git</a>
</summary>
<pre><code class="python">#!/usr/bin/env python3
# -*- coding: utf-8 -*-
&#34;&#34;&#34;
Copyright 2020 Huawei Technologies Co., Ltd
Licensed under the Apache License, Version 2.0 (the &#34;License&#34;);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &#34;AS IS&#34; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
&#34;&#34;&#34;
import numpy as np

# error code
ACL_SUCCESS = 0

# rule for mem
ACL_MEM_MALLOC_HUGE_FIRST = 0
ACL_MEM_MALLOC_HUGE_ONLY = 1
ACL_MEM_MALLOC_NORMAL_ONLY = 2

# rule for memory copy
ACL_MEMCPY_HOST_TO_HOST = 0
ACL_MEMCPY_HOST_TO_DEVICE = 1
ACL_MEMCPY_DEVICE_TO_HOST = 2
ACL_MEMCPY_DEVICE_TO_DEVICE = 3

# NUMPY data type
# ptr_to_numpy
NPY_BOOL = 0
NPY_BYTE = 1
NPY_UBYTE = 2
NPY_SHORT = 3
NPY_USHORT = 4
NPY_INT = 5
NPY_UINT = 6
NPY_LONG = 7
NPY_ULONG = 8
NPY_LONGLONG = 9
NPY_ULONGLONG = 10
NPY_FLOAT32 = 11
NPY_DOUBLE = 12
NPY_FLOAT16 = 23

# data format
ACL_FORMAT_UNDEFINED = -1
ACL_FORMAT_NCHW = 0
ACL_FORMAT_NHWC = 1
ACL_FORMAT_ND = 2
ACL_FORMAT_NC1HWC0 = 3
ACL_FORMAT_FRACTAL_Z = 4


# data type
# get_input_data_type
ACL_DT_UNDEFINED = -1
ACL_FLOAT = 0
ACL_FLOAT16 = 1
ACL_INT8 = 2
ACL_INT32 = 3
ACL_UINT8 = 4
ACL_INT16 = 6
ACL_UINT16 = 7
ACL_UINT32 = 8
ACL_INT64 = 9
ACL_UINT64 = 10
ACL_DOUBLE = 11
ACL_BOOL = 12


ACL_DDR_MEM           = 0 # DDR内存，DDR上所有大页内存+普通内存 
ACL_HBM_MEM           = 1 # HBM内存，HBM上所有大页内存+普通内存 
ACL_DDR_MEM_HUGE      = 2 # #DDR大页内存 
ACL_DDR_MEM_NORMAL    = 3 # DDR普通内存
ACL_HBM_MEM_HUGE      = 4 # HBM大页内存 
ACL_HBM_MEM_NORMAL    = 5 # HBM普通内存 
ACL_DDR_MEM_P2P_HUGE  = 6 # DDR中用于Device间数据复制的 大页内存 
ACL_DDR_MEM_P2P_NORMAL= 7 # DDR中用于Device间数据复 制的普通内存 
ACL_HBM_MEM_P2P_HUGE  = 8 # HBM中用于Device间数据复制 的大页内存 
ACL_HBM_MEM_P2P_NORMAL= 9 # HBM中用于Device间数据复 制的普通内存

# pyav stream.codec_context profile
PROFILE_HEVC_MAIN = 1
PROFILE_H264_BASE = 66
PROFILE_H264_MAIN = 77
PROFILE_H264_HIGH = 100

# video encoding protocol
H265_MAIN_LEVEL = 0
H264_BASELINE_LEVEL = 1
H264_MAIN_LEVEL = 2
H264_HIGH_LEVEL = 3


# dvpp pixel format
PIXEL_FORMAT_YUV_400 = 0  # YUV400 8bit
PIXEL_FORMAT_YUV_SEMIPLANAR_420 = 1  # YUV420SP NV12 8bit
PIXEL_FORMAT_YVU_SEMIPLANAR_420 = 2  # YUV420SP NV21 8bit
PIXEL_FORMAT_YUV_SEMIPLANAR_422 = 3  # YUV422SP NV12 8bit
PIXEL_FORMAT_YVU_SEMIPLANAR_422 = 4  # YUV422SP NV21 8bit
PIXEL_FORMAT_YUV_SEMIPLANAR_444 = 5  # YUV444SP NV12 8bit
PIXEL_FORMAT_YVU_SEMIPLANAR_444 = 6  # YUV444SP NV21 8bit
PIXEL_FORMAT_YUYV_PACKED_422 = 7  # YUV422P YUYV 8bit
PIXEL_FORMAT_UYVY_PACKED_422 = 8  # YUV422P UYVY 8bit
PIXEL_FORMAT_YVYU_PACKED_422 = 9  # YUV422P YVYU 8bit
PIXEL_FORMAT_VYUY_PACKED_422 = 10  # YUV422P VYUY 8bit
PIXEL_FORMAT_YUV_PACKED_444 = 11  # YUV444P 8bit
PIXEL_FORMAT_RGB_888 = 12  # RGB888
PIXEL_FORMAT_BGR_888 = 13  # BGR888
PIXEL_FORMAT_ARGB_8888 = 14  # ARGB8888
PIXEL_FORMAT_ABGR_8888 = 15  # ABGR8888
PIXEL_FORMAT_RGBA_8888 = 16  # RGBA8888
PIXEL_FORMAT_BGRA_8888 = 17  # BGRA8888
PIXEL_FORMAT_YUV_SEMI_PLANNER_420_10BIT = 18  # YUV420SP 10bit
PIXEL_FORMAT_YVU_SEMI_PLANNER_420_10BIT = 19  # YVU420sp 10bit
PIXEL_FORMAT_YVU_PLANAR_420 = 20  # YUV420P 8bit
PIXEL_FORMAT_YVU_PLANAR_422 = 21
PIXEL_FORMAT_YVU_PLANAR_444 = 22
PIXEL_FORMAT_RGB_444 = 23
PIXEL_FORMAT_BGR_444 = 24
PIXEL_FORMAT_ARGB_4444 = 25
PIXEL_FORMAT_ABGR_4444 = 26
PIXEL_FORMAT_RGBA_4444 = 27
PIXEL_FORMAT_BGRA_4444 = 28
PIXEL_FORMAT_RGB_555 = 29
PIXEL_FORMAT_BGR_555 = 30
PIXEL_FORMAT_RGB_565 = 31
PIXEL_FORMAT_BGR_565 = 32
PIXEL_FORMAT_ARGB_1555 = 33
PIXEL_FORMAT_ABGR_1555 = 34
PIXEL_FORMAT_RGBA_1555 = 35
PIXEL_FORMAT_BGRA_1555 = 36
PIXEL_FORMAT_ARGB_8565 = 37
PIXEL_FORMAT_ABGR_8565 = 38
PIXEL_FORMAT_RGBA_8565 = 39
PIXEL_FORMAT_BGRA_8565 = 40
PIXEL_FORMAT_RGB_BAYER_8BPP = 50
PIXEL_FORMAT_RGB_BAYER_10BPP = 51
PIXEL_FORMAT_RGB_BAYER_12BPP = 52
PIXEL_FORMAT_RGB_BAYER_14BPP = 53
PIXEL_FORMAT_RGB_BAYER_16BPP = 54
PIXEL_FORMAT_BGR_888_PLANAR = 70
PIXEL_FORMAT_HSV_888_PACKAGE = 71
PIXEL_FORMAT_HSV_888_PLANAR = 72
PIXEL_FORMAT_LAB_888_PACKAGE = 73
PIXEL_FORMAT_LAB_888_PLANAR = 74
PIXEL_FORMAT_S8C1 = 75
PIXEL_FORMAT_S8C2_PACKAGE = 76
PIXEL_FORMAT_S8C2_PLANAR = 77
PIXEL_FORMAT_S16C1 = 78
PIXEL_FORMAT_U8C1 = 79
PIXEL_FORMAT_U16C1 = 80
PIXEL_FORMAT_S32C1 = 81
PIXEL_FORMAT_U32C1 = 82
PIXEL_FORMAT_U64C1 = 83
PIXEL_FORMAT_S64C1 = 84
PIXEL_FORMAT_BUTT = 1003
PIXEL_FORMAT_UNKNOWN = 10000

DVPP = 1
DEVICE = 2
HOST = 3

#log
DEBUG = 0
INFO = 1
WARNING = 2
ERROR = 3

interp_codes = {
    &#39;huawei&#39;: 0,
    &#39;bilinear&#39;: 1,
    &#39;nearest&#39;: 2,
    &#39;bicubic&#39;: 3,
    &#39;area&#39;: 4,
    &#39;lanczos&#39;: 5
}

# images format
IMG_EXT_ENC = [
    &#39;.png&#39;,
    &#39;.PNG&#39;,
    &#39;.jpg&#39;,
    &#39;.JPG&#39;,
    &#39;.jpeg&#39;,
    &#39;.JPEG&#39;
]

yuv420 = [
    PIXEL_FORMAT_YUV_SEMIPLANAR_420, 
    PIXEL_FORMAT_YVU_SEMIPLANAR_420
]

pix_fmt_map = {
    &#39;yuv400&#39;   : PIXEL_FORMAT_YUV_400,
    &#39;yuv420p&#39;  : PIXEL_FORMAT_YUV_SEMIPLANAR_420,
    &#39;yuvj420p&#39; : PIXEL_FORMAT_YVU_SEMIPLANAR_420,
    &#39;yuv422p&#39;  : PIXEL_FORMAT_YUV_SEMIPLANAR_422,
    &#39;yuvj422p&#39; : PIXEL_FORMAT_YVU_SEMIPLANAR_422,
    &#39;yuv444p&#39;  : PIXEL_FORMAT_YUV_SEMIPLANAR_444,
    &#39;yuvj444p&#39; : PIXEL_FORMAT_YVU_SEMIPLANAR_444,

    &#39;rgb&#39;  : PIXEL_FORMAT_RGB_888, # RGB88
    &#39;bgr&#39;  : PIXEL_FORMAT_BGR_888, # BGR88
    &#39;argb&#39; : PIXEL_FORMAT_ARGB_8888, # ARG
    &#39;abgr&#39; : PIXEL_FORMAT_ABGR_8888, # ABG
    &#39;rgba&#39; : PIXEL_FORMAT_RGBA_8888, # RGB
    &#39;bgra&#39; : PIXEL_FORMAT_BGRA_8888  # BGR
}

en_type_map = {
    PROFILE_HEVC_MAIN : H265_MAIN_LEVEL,
    PROFILE_H264_BASE : H264_BASELINE_LEVEL,
    PROFILE_H264_MAIN : H264_MAIN_LEVEL,
    PROFILE_H264_HIGH : H264_HIGH_LEVEL
}


dtype_dict = {
    ACL_FLOAT  : np.dtype(&#39;float32&#39;),
    ACL_FLOAT16: np.dtype(&#39;float16&#39;),
    ACL_INT8   : np.dtype(&#39;int8&#39;)   ,
    ACL_INT32  : np.dtype(&#39;int32&#39;)  ,
    ACL_UINT8  : np.dtype(&#39;uint8&#39;)  ,
    ACL_INT16  : np.dtype(&#39;int16&#39;)  ,
    ACL_UINT16 : np.dtype(&#39;uint16&#39;) ,
    ACL_UINT32 : np.dtype(&#39;uint32&#39;) ,
    ACL_INT64  : np.dtype(&#39;int64&#39;)  ,
    ACL_UINT64 : np.dtype(&#39;uint64&#39;) ,
    ACL_DOUBLE : np.dtype(&#39;float64&#39;),
    ACL_BOOL   : np.dtype(&#39;bool&#39;)   
}

tensor_fmt_map = {
    ACL_FORMAT_UNDEFINED: &#39;UNDEFINED&#39;,
    ACL_FORMAT_NCHW     : &#39;NCHW&#39;,
    ACL_FORMAT_NHWC     : &#39;NHWC&#39;,
    ACL_FORMAT_ND       : &#39;ND&#39;,
    ACL_FORMAT_NC1HWC0  : &#39;NC1HWC0&#39;,
    ACL_FORMAT_FRACTAL_Z: &#39;FRACTAL_Z&#39;
}

tensor_fmt_dict = {
    &#39;UNDEFINE&#39;  : ACL_FORMAT_UNDEFINED,
    &#39;NCHW&#39;      : ACL_FORMAT_NCHW,
    &#39;NHWC&#39;      : ACL_FORMAT_NHWC,
    &#39;ND&#39;        : ACL_FORMAT_ND,
    &#39;NC1HWC0&#39;   : ACL_FORMAT_NC1HWC0,
    &#39;FRACTAL_Z&#39; : ACL_FORMAT_FRACTAL_Z
}

numpy_dict = {
    np.dtype(&#39;float32&#39;) : NPY_FLOAT32,
    np.dtype(&#39;float16&#39;) : NPY_FLOAT16,
    np.dtype(&#39;int8&#39;)    : NPY_BYTE,
    np.dtype(&#39;int32&#39;)   : NPY_INT,
    np.dtype(&#39;uint8&#39;)   : NPY_UBYTE,
    np.dtype(&#39;int16&#39;)   : NPY_SHORT,
    np.dtype(&#39;uint16&#39;)  : NPY_USHORT,
    np.dtype(&#39;uint32&#39;)  : NPY_UINT,
    np.dtype(&#39;int64&#39;)   : NPY_LONG,
    np.dtype(&#39;uint64&#39;)  : NPY_ULONG,
    np.dtype(&#39;float64&#39;) : NPY_DOUBLE,
    np.dtype(&#39;bool&#39;)    : NPY_BOOL
}</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
</section>
<section>
</section>
</article>
<nav id="sidebar">
<header>
<a class="homelink" rel="home" title="ascendfly Home" href="https://gitee.com/ascend-fae/ascendfly">
<img src="https://bazige.github.io/ascend/logo/logo.png" alt=""> ascendfly
</a>
</header>
<div class="gcse-search" style="height: 70px"
data-as_oq="site:bazige.github.io inurl:github.com/ascendfly"
data-gaCategoryParameter="ascend.common.const">
</div>
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="ascend.common" href="index.html">ascend.common</a></code></li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p><span style="color:#ddd">&#21328;</span></p>
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
</footer>
</body>
</html>